package cn.edu.scau.cmi.wusonglang.composite.consistent;

import java.util.ArrayList;
import java.util.HashSet;
import java.util.Iterator;
import java.util.Set;

public class Composite implements Nation{

	private Set<Nation> countryList;
	
	public Composite() {
		countryList = new HashSet<Nation>();
	}
	
	public void add(Nation country) {
		if(country!=null) {
			countryList.add(country);
		}
	}
	
	public void remove(Nation country) {
		if(country!=null) {
			countryList.remove(country);
		}
	}
	
	public Iterator<Nation> elements(){
		return countryList.iterator();
	}
	
	@Override
	public String sayHallo() {
		String saying = "This is the united nation\n";
		int len = countryList.size();
		for(Nation country :countryList)
			saying = saying + country.sayHallo() + "\n";
		return saying;
	}
	
	public int getSize() {
		return countryList.size();
	}

}
